package part1.api.io;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

/**
 * 缓冲字符输入流读取文本数据
 */
public class BRDemo {
    public static void main(String[] args) throws IOException {
        //文件流(字节流，低级流)
        FileInputStream fis = new FileInputStream("pw.txt");
        //转换流(字节流，高级流)
        InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
        //缓冲字符流(字符流，高级流)
        BufferedReader br = new BufferedReader(isr);
        /*
           String readLine():
           不会读字符串后面的空格符
           但是读取的是单独空行则会返回空字符串""
         */
        String line;
        while ((line=br.readLine()) != null){
            System.out.println(line); //换行操作
            //System.out.print(line); //没有换行操作
        }
        br.close();
    }
}
